home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / interapplication comm / moreappleevents / processhelpers.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  4.5 KB  |  171 lines

  1. /*
  2.     File:        ProcessHelpers.h
  3.  
  4.     Contains:    Functions to help you when you are working with processes.
  5.  
  6.     Written by: Andy Bachorski    
  7.  
  8.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/21/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #if PRAGMA_ONCE
  25.     #pragma once
  26. #endif
  27.  
  28. #ifndef _PROCESS_HELPERS_
  29. #define _PROCESS_HELPERS_
  30.  
  31.  
  32. //******************************************************************************
  33.  
  34. //    A private conditionals file to setup the build environment for this project.
  35.  
  36. #include "PrivateConditionals.h"
  37.  
  38.  
  39. //**********    Universal Headers        ****************************************
  40.  
  41. #include <Processes.h>
  42. #include <Types.h>
  43.  
  44.  
  45.  
  46. //******************************************************************************
  47.  
  48.  
  49. #ifdef __cplusplus
  50.     extern "C" {
  51. #endif
  52.  
  53. #if PRAGMA_IMPORT
  54.     #pragma import on
  55. #endif
  56.  
  57. #if PRAGMA_STRUCT_ALIGN
  58.     #pragma options align=mac68k
  59. #elif PRAGMA_STRUCT_PACKPUSH
  60.     #pragma pack(push, 2)
  61. #elif PRAGMA_STRUCT_PACK
  62.     #pragma pack(2)
  63. #endif
  64.  
  65.  
  66. //******************************************************************************
  67.  
  68. pascal    OSErr    FindProcessBySignature( const OSType targetType,
  69.                                         const OSType targetCreator,
  70.                                               ProcessSerialNumberPtr psnPtr );
  71. /*
  72.     Return a ProcessSerialNumber for a process whose signature (type and creator)
  73.     matches the input values.  This routine will find the first process that
  74.     matches the type and creator.
  75.     
  76.     The ProcessSerialNumber will be kNoProcess is the requested process cannot
  77.     be found. 
  78.  
  79.     targetType        input:    The file type of the process to be found.
  80.     targetCreator    input:    The creator type of the process to be found.
  81.     psnPtr            input:    Pointer to a ProcessSerialNumber.
  82.                     output:    A valid PSN or kNoProcess in no match is found.
  83.     
  84.     RESULT CODES
  85.     ____________
  86.     noErr               0    No error
  87.     procNotFound    –600    No process matched specified type and creator
  88.     ____________
  89. */
  90.  
  91. //******************************************************************************
  92.  
  93. pascal    OSErr    GetProcessName( const ProcessSerialNumberPtr psnPtr,
  94.                                 StringPtr processName );
  95. /*
  96.     Returns the name of the process specified by ProcessSerialNumberPtr.
  97.     
  98.     The string pointed to by processName will be untouched if the process
  99.     can't be found. 
  100.  
  101.     psnPtr            input:    The process whose name you want.
  102.     targetCreator    input:    The creator type of the process to be found.
  103.     processName        input:    Pointer to a Str31 for the process name.
  104.                     output:    The process name.
  105.     
  106.     RESULT CODES
  107.     ____________
  108.     noErr               0    No error
  109.     paramErr         –50    Process serial number is invalid
  110.     ____________
  111. */
  112.  
  113. //******************************************************************************
  114.  
  115. pascal    OSErr    GetProcessTypeSignature( const ProcessSerialNumberPtr psnPtr,
  116.                                          OSType *processType,
  117.                                          OSType *processSignature );
  118. /*
  119.     Returns the name of the process specified by ProcessSerialNumberPtr.
  120.     
  121.     processType and processSignature will be untouched if the process
  122.     can't be found. 
  123.  
  124.     psnPtr                input:    The process whose name you want.
  125.     processType            output:    The process's type.
  126.     processSignature    output:    The process's signature.
  127.     
  128.     RESULT CODES
  129.     ____________
  130.     noErr               0    No error
  131.     paramErr         –50    Process serial number is invalid
  132.     ____________
  133. */
  134.  
  135. //******************************************************************************
  136.  
  137. pascal    OSErr    GetCurrentProcessFSSpec( FSSpec *spec );
  138. /*
  139.     Returns the FSSpec for the process specified by ProcessSerialNumberPtr.
  140.     
  141.     spec                output:    The process's FSSpec.
  142.     
  143.     RESULT CODES
  144.     ____________
  145.     noErr               0    No error
  146.     paramErr         –50    Process serial number is invalid
  147.     ____________
  148. */
  149.  
  150. //******************************************************************************
  151.  
  152. #if PRAGMA_STRUCT_ALIGN
  153.     #pragma options align=reset
  154. #elif PRAGMA_STRUCT_PACKPUSH
  155.     #pragma pack(pop)
  156. #elif PRAGMA_STRUCT_PACK
  157.     #pragma pack()
  158. #endif
  159.  
  160. #ifdef PRAGMA_IMPORT_OFF
  161. #pragma import off
  162. #elif PRAGMA_IMPORT
  163. #pragma import reset
  164. #endif
  165.  
  166. #ifdef __cplusplus
  167. }
  168. #endif
  169.  
  170. #endif// _PROCESS_HELPERS_
  171.